import { RouteRecordRaw } from 'vue-router'
import ErrorNotFound from 'src/pages/ErrorNotFound.vue'

// @mimas: allocated root path of current app, defined in package.json
const appPath = process.env.appPath as string

const routes: RouteRecordRaw[] = [
  {
    path: appPath,
    component: () => import('layouts/MainLayout.vue'),
    children:
      [

        {
          path: '',
          redirect: appPath + '/book'
        },
        {
          path: 'book',
          component: () => import('src/pages/meeting/BookMeeting.vue')
        },
        {
          path: 'my-bookings',
          component: () => import('src/pages/meeting/MyBookings.vue')
        },
        {
          path: 'settings',
          component: () => import('src/pages/meeting/Settings.vue')
        },
        {
          path: 'help',
          component: () => import('src/pages/meeting/Help.vue')
        },

        // 管理员路由
        {
          path: 'dashboard',
          component: () => import('src/pages/admin/Dashboard.vue')
        },
        {
          path: 'users',
          component: () => import('src/pages/admin/Users.vue')
        },

        // // old
        // {
        //   path: 'meetings',
        //   component: () => import('src/pages/admin/Meetings.vue')
        // },

        // new
        {
          path: 'reservations',
          component: () => import('src/pages/admin/ReservationManage.vue')
        },
        {
          path: 'roles',
          component: () => import('src/pages/admin/Roles.vue')
        },
        {
          path: 'groups',
          component: () => import('src/pages/admin/Groups.vue')
        },
        {
          path: 'system',
          component: () => import('src/pages/admin/System.vue')
        },

        // system
        {
          path: 'info',
          component: () => import('pages/info/InfoIndex.vue'),
          redirect: appPath + '/info/about',
          children: [
            {
              path: 'about',
              component: () => import('pages/info/AboutPage.vue')
            }
          ]
        }
      ]

  },

  // Always leave this as last one,
  // but you can also remove it
  {
    path: '/:catchAll(.*)*',
    component: ErrorNotFound
  }
]

export default routes
